package com.tbit.config.mvc.converter;

import com.tbit.uqbike.enums.TagBindStatus;
import org.springframework.core.convert.converter.Converter;

import java.util.Objects;

/**
 * TagBindStatus 转换器
 * String -> TagBindStatus
 *
 *
 * @author <a href="mailto:chen.chaoxiong@tbit.com.cn">ChenChaoXiong</a>
 * @since 2024/7/10
 */
public class StringToTagBindStatusConverter implements Converter<String, TagBindStatus> {
    @Override
    public TagBindStatus convert(String source) {
        TagBindStatus status = TagBindStatus.getTagBindStatsByCode(source);
        if (Objects.isNull(status)) {
            throw new IllegalArgumentException("Invalid TagBindStatus code: " + source);
        }
        return status;
    }
}